<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
        crossorigin="anonymous">
    <title>Document</title>
    <script src="http://mat1.gtimg.com/libs/jquery2/2.2.0/jquery.js"></script>
</head>

<body>
    <div class="container" style="margin-top:50px; ">
        <h1></h1>
        <form action="http://106.12.24.181/users" method="POST" class="form-horizontal" style="margin-top:50px;margin-bottom:50px;">
            <div class="form-group">
                <label for="username" class="col-sm-2 control-label">账户</label>
                <div class="col-sm-4">
                    <input id="username" type="text" name="username" class="form-control" placeholder="Email / phone">
                </div>
            </div>
            <div class="form-group">
                <label for="password" class="col-sm-2 control-label">密码</label>
                <div class="col-sm-4">
                    <input id="password" type="password" name="password" class="form-control" placeholder="password">
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button id="loginBtn" type="button" class="btn btn-success">立即登录</button>
                </div>
            </div>
        </form>
    </div>
</body>
<script>
    $('#loginBtn').on('click', () => {
        var username = $('#username').val();
        var password = $('#password').val();
        $.ajax({
            url: '/login',
            type: 'post',
            success: (data) => {
                $('form').hide();
                $('h1').text(data)
            },
            data: {
                username: username,
                password: password,
            },
        });
    });

</script>

</html>